package com.zyh.work2

object ComputerTest {
  def main(args: Array[String]): Unit = {
    val pc = new PC()
    pc.CPU = "A14"
    pc.memory = "4G"
    pc.disk = "256G"
    pc.brand = "apple"
    val notePad: NotePad = new NotePad("白色")
    println(pc)
    println(pc.getDetails)
    println(notePad)
    println(notePad.getDetails)
  }
}
case class Computer(){
  var CPU: String = _
  var memory: String = _
  var disk: String = _

  def this(CPU:String,memory:String,disk:String) = {
    this
    this.CPU=CPU
    this.memory=memory
    this.disk=disk
  }

  def getDetails: String = {
    s"CPU = $CPU,memory = $memory,disk = $disk"
  }
}
class PC() extends Computer{
  var brand: String = _

  //  def this(CPU:String,memory:String,disk:String) = {
  //    this
  //    this.CPU=CPU
  //    this.memory=memory
  //    this.disk=disk
  //  }
  override def toString: String = {
    s"$memory,$memory,$disk,$brand"
  }
}
class NotePad(color:String) extends Computer{
  override def toString: String = {
    s"$CPU,$memory,$disk,$color"
  }
}